PageBox |
|
FAQ | Dev site | .NET version | Customization | Install | Grid | Active Naming | Grid API |
PageBox for .NET customizationDeliveriesYou can download PageBox and its repository for .NET in Zip format: The repository of PageBox for .NET is made of the following files:
The Repository archive also includes a TestRepoCleanup directory that you can use
TestRepoCleanup contains the following files:
PageBox for .NET is made of the following files:
The Grid API of PageBox for .NET (pageboxgrid.zip) is made of the following files:
The ActiveNaming Web service is described in the Active Naming documentation and in the Grid presentation. The Grid API is described in the Grid API documentation and in the Grid presentation.
RepositorySubscriber.csThe Subscriber class contains archs, an associative array of the presentations deployed or pending for deployment. Subscriber has three methods:
RepoSubs.csThe RepoSubs class contains subscribers, an associative array of the subscribing PageBoxes and asubscribers, an associative array of the archive subscribers. RepoSubs has eleven methods:
When a new PageBox is subscribed, it receives all presentations defined in RepoArchs. RepoSubs manages subscribers.xml. Here is an example:
RepoArch.csThe RepoArchs class contains four associative arrays:
RepoArch has nine methods:
When a new presentation is added, it is deployed on every subscriber and added to the Subscriber objects. Presentations are not automatically added to archive subscribers but when an archive subscriber has subscribed a presentation, it receives presentation updates. RepoArchs manages archives.xml. Here is an example:
Deployer.csThe Deployer class has two static methods:
RepoArchs and RepoSubs extend Deployer and invoke its methods. Deploy.csDeploy.cs is a SOAP proxy. It has been generated from the Deploy Web service of PageBox using wsdl.exe. The constructor has been modified to set the Web service URL, which has to be the subscriber URL. Global.asax.csGlobal class contains two static members, subRep, a RepoSubs singleton and archRep, a RepoArchs singleton. Global restores archRep and subRep at the first request performed on the Repository application in Application_BeginRequest. Application_BeginRequest calls restore to restore subRep and archRep. restore uses RepoArchs and RepoSubs’s constructors with an XmlReader to restore subRep and archRep from subscribers.xml and archives.xml. Global class contains two methods, saveSubRep to save subRep on subscribers.xml and saveArchRep to save archRep on archives.xml. These methods call the WriteXml methods of RepoSubs and RepoArchs. subcriber.aspx.csThe SubscriberWF class manages a form that
The bind method binds an ArrayList to the Datagrid. This ArrayList contains SubscriberEntry objects. bind populates the ArrayList from RepoSubs.subscribers. bind is called by Page_Load, subscriberDB_unsubscribe, Form1_subscribe, Form1_unsubscribe, Form1_force, Form1_refresh. subscriber.aspx provides two buttons to remove subscribers Unsubscribe and Force and a button to refresh the Datagrid, refresh. When the user clicks one of these buttons, Form1_subscribe, Form1_unsubscribe, Form1_force or Form1_refresh is invoked. Form1_subscribe invokes RepoSubs.subscribe. Form1_unsubscribe and Form1_force invoke RepoSubs.unsubscribe. Force allows removing a PageBox that doesn’t exist (anymore) whereas Unsubscribe keeps the subscriber in "pending unsubscribe" state. In that state the subscriber doesn’t receive new archives. The Datagrid rows have also two buttons, unsub and force. In InitializeComponent we added subscriberDB_unsubscribe to the Datagrid’s ItemCommand as DataGridCommandEventHandler. When the user clicks either on unsub or force buttons, subscriberDB_unsubscribe is called. subscriberDB_unsubscribe calls RepoSubs.unsubscribe. publisher.aspx.csThe publisher class manages a form that
If you put authentication in place then only publishers and administrators can use that form and a publisher can only see the presentations and batchs that she or he has published. A user is a publisher if its user id is defined in RepoArchs.publishers. A user is an administrator if its user id is defined in RepoArchs.administrators. RepoArchs restores publishers and administrators from authorization.xml. Here is an example of authorization.xml:
authorization.xml handles role authorizations. Authentication is defined in web.config. By default we use Form based authentication with login-form.aspx:
It is very important to define the <authorization> element and to forbid unauthenticated access to the Repository application. When authentication is in place:
The bind method binds an ArrayList to the Datagrid. This ArrayList contains PublisherEntry objects. bind populates the ArrayList from RepoArchs.archives and RepoArchs.docs. bind is called by Page_Load, archUpload, refresh, archiveDB_delete. publisher.aspx provides a button to upload archives Upload and a button to refresh the Datagrid, Refresh. When the user clicks one of these buttons, archUpload or refresh is invoked. archUpload processes POST method upload as defined in RFC 1867. The upload code is quite simple:
archUpload saves the uploaded file in downloadPath, which is Repository-Directory\..\download as defined in Global.asax.cs with a Repository name which is the same as the uploaded file (arch). Then it calls RepoArchs.add to add the archive to RepoArchs.archives and trigger the deployment of the presentation/batch on subscribers. Beside the presentation location, publisher.aspx allows specifying the URL of the presentation documentation. archUpload retrieves it in docURL.value. The Datagrid rows have also two buttons, Delete and Force. In InitializeComponent we added archiveDB_delete to the Datagrid’s ItemCommand as DataGridCommandEventHandler. When the user clicks either on Delete or Force buttons, archiveDB_delete is called. archiveDB_delete calls RepoArchs.delete. In both cases publisher send an undeploy(presentation) to all subscribers and removes the presentation file from the repository. If the undeploy succeeds, the presentation is removed from the archive list of the subscriber. If the undeploy fails for one subscriber:
asubscriber.aspx.csThe asubscriber class is very similar to subscriber.aspx.cs. It manages a form that
The bind method binds an ArrayList to the Datagrid. This ArrayList contains SubscriberEntry objects. bind populates the ArrayList from RepoSubs.subscribers. bind is called by Page_Load, subscriberDB_handle, Form1_subscribe, Form1_unsubscribe, Form1_force, Form1_refresh. asubscriber.aspx provides two buttons to remove subscribers Unsubscribe and Force and a button to refresh the Datagrid, refresh. When the user clicks one of these buttons, Form1_subscribe, Form1_unsubscribe, Form1_force or Form1_refresh is invoked. Form1_subscribe invokes RepoSubs.asubscribe. Form1_unsubscribe and Form1_force invoke RepoSubs.unasubscribe. Force allows removing a PageBox that doesn’t exist (anymore) whereas Unsubscribe keeps the subscriber in "pending unsubscribe" state. In that state the subscriber doesn’t receive new archives. The Datagrid rows have also two buttons, unsub and force. In InitializeComponent we added subscriberDB_handle to the Datagrid’s ItemCommand as DataGridCommandEventHandler. When the user clicks either on unsub or force buttons, subscriberDB_handle is called. subscriberDB_handle calls RepoSubs.unasubscribe. The Datagrid rows also contain a link to the aselect page. This link is created in asubscriber.aspx by <asp:HyperLinkColumn HeaderText=" " ItemStyle-Width="7%" Text="Archives" DataNavigateUrlField="PageBox" DataNavigateUrlFormatString="aselect.aspx?subscriber={0}"/> When you click on such a link, aselect is invoked in GET mode with a subscriber parameter containing the URL of the PageBox Web service. aselect.aspx.csaselect.aspx.cs manages a form that:
The form operates by delta:
To support this feature we use a MultiGrid class that extends DataGrid. MultiGrid is based on the article of Dino Esposito published in the MSDN issue of January 2002. It includes two changes:
The bind method binds an ArrayList to the MultiGrid. This ArrayList contains SelectorEntry objects. bind populates the ArrayList from RepoArchs.archives and RepoArchs.docs. bind is called by Page_Load and Form1_refresh. Form1_refresh reads SelectedItems, enumerates the archives and adds or remove archives on the subscription list accordingly. download.aspx.csdownload.aspx allows downloading presentations from Repositories without subscription: When the presentation is updated, it is not deployed on the download site. The download site doesn’t need a PageBox. The download class manages a form that lists the uploaded presentations and batches using a Datagrid. It implements one method, Page_Load that populates an ArrayList from RepoArchs.archives and RepoArchs.docs and binds it to the Datagrid. This ArrayList contains DownloadEntry objects. A DownloadEntry contains both the presentation name (Archive) and download URL (ArchiveURL). download.aspx provides a link to download presentations and batches, defined with: <asp:HyperLinkColumn Target="_self" DataNavigateUrlField="ArchiveURL" DataTextField="Archive" ItemStyle-Width="28%" HeaderText="Archive"/> Log.csLog.cs provides a write static method. write writes on log.rep entries that contain:
audit.aspx.csaudit.aspx manages a form that displays log.rep and allows removing log.rep. If you put authentication in place then only administrators can use that form. The audit class implements two methods, clear and include. Both methods first check that the user is an administrator. clear removes the log.rep file. include calls Response.WriteFile("log.rep") clear is invoked through the Clear button. include is invoked by <% include(); %>. Retry.asmxIf it is properly configured, RepoCleanup calls the Retry.asmx every 30 minutes to retry pending deploys and undeploys. With this mechanism PageBox for .NET can cope with transient conditions such as Pagebox server reboot. Because Retry.asmx is implemented as a Web Service a single RepoCleanup can monitor a set of Repositories on different machines. Retry.asmx invokes the cleanup method of RepoSubs.cs. Form based authentication, which is the preferred authentication scheme for the Repository, is not suitable for Web services. Therefore Retry.asmx is installed on a WebServices subdirectory of the repository. WebServices contains a specific web.config that disables form-based authentication:
Retry.asmx implements a custom authentication and authorization mechanism consistent with the rest of the Repository: only Repository administrators are allowed to issue cleanup requests. This mechanism is quite simple.
RepoQuery.asmxRepoQuery has two methods:
PageBoxPbArch.csThe PbArch class describes presentations and batchs deployed on a PageBox. PbArch contains three associative tables:
The InstallCommand class has three fields:
To process a command, PbArch uses a ProcessStartInfo object:
A command has a mandatory parameter, which is the archive path. The parameter string is built like this:
You can put more than one parameter in Parameter-prefix but they must be followed by the archive full path. restorePbCmd restores inflate and remove associative tables from pbCmd.xml. To restore inflate or remove, it invokes the restoreHash method. Here is an example of pbCmd.xml file:
When the PageBox receives a deployment request for an archive xxxx.zip, it will call a WSH script inflate.js /arch:archive-directory\\xxxx.zip When the PageBox receives a undeployment request for an archive xxxx.zip, it will call a WSH script inflate.js /del /arch;archive-directory\\xxxx.zip When the PageBox receives a deployment request for an archive xxxx.jar, it won’t call a script because "-" stands for "Just copy this archive". Here is an example of command (inflate.js):
The archives associative table contains Archive objects. The Archive class maintains the download location, the owner, size, upload time, documentation URL and state of the archive. Archive has a constructor to create a new Archive object, a constructor to restore an Archive object from PbArchives.xml (with a XmlReader parameter) and a method WriteXml to serialize onto PbArchives.xml. The PbArchs constructor with a XMLReader parameter restores the archives associative table from PbArchive.xml whereas PbArchs’ WriteXml serializes the archive associative table onto PbArchives.xml. PbArchive.xml looks like this:
PbArchs has two other methods:
Global.asax.csGlobal class contains a static member, pbArchives, a PbArchs singleton. Global restores pbArchives at the first request performed on the Repository application in Application_BeginRequest. Application_BeginRequest calls restore to restore pbArchives. restore uses PbArchs’ constructor with an XmlReader to restore pbArchives from pbArchives.xml. Global class contains a savePbArchives method to save pbArchives on pbArchives.xml. This method call the WriteXml method of PbArchs. Deploy.asmx.csDeploy.asmx is the deployment Web service. Deploy.asmx.cs implements two Web methods, add that invokes the add method of the PbArchs singleton and delete that invokes the delete method of the PbArchs singleton. update.aspx.csThe update class manages a form that lists the deployed presentations The Page_Load method binds an ArrayList to the Datagrid. This ArrayList contains UpdateEntry objects. Page_Load populates the ArrayList from PbArchs.archives. Log.csLog.cs provides a write static method. write writes on log.html entries that contain:
audit.aspx.csaudit.aspx manages a form that displays log.rep and allows removing log.html. The audit class implements two methods, clear and include. clear removes the log.html file. include calls Response.WriteFile("log.html") clear is invoked through the Clear button. include is invoked by <% include(); %>. Query.asmxQuery.asmx has a single method of the Query Web service, GetSubscribers. GetSubscribers retrieves the URL of the Repository RepoQuery Web service, invokes this RepoQuery Web service to get the URLs of all other subscribers and archive subscribers to the presentation and returns this list to the requestor – typically a presentation or application installed by the PageBox. RepoCleanupRepoCleanup is a Windows service (what used to be called a NT service). RepoCleanup manages a set of Repositories. Every 30 minutes RepoCleanup calls the Retry.asmx of every Repository that it knows to retry pending deploys and undeploys. With this mechanism PageBox for .NET can cope with transient conditions such as Pagebox server reboot. Cleanup.csCleanup.cs is the core class of the Windows service. It implements two methods:
OnStart first retrieves the full path of the configuration file (cleanup.xml) and the logging mode. It first looks in the registry. As a regular Windows service, Cleanup is defined in the HKEY_LOCAL_MACHINE hive in SYSTEM\CurrentControlSet\Services\Cleanup. OnStart expects to find the configuration path in SYSTEM\CurrentControlSet\Services\Cleanup\Parameters\ConfigFile and the logging mode in SYSTEM\CurrentControlSet\Services\Cleanup\Parameters\LogDebug. Then OnStart looks at the startup parameters. It expects to find the path and optionally the logging mode. If the path is not set either in the registry or as a startup parameter, OnStart writes an error on the Application event log with RepoCleanup as source: Cleanup.OnStart service without startup parameter (cleanup.xml full path) If the startup parameters are set, OnStart creates or updates the corresponding registry entries. Then OnStart creates a CleanupThread and a worker thread where the ThreadRun method of CleanupThread will run. ThreadRun waits 30 minutes or for a pulse. Then it checks a toStop Boolean. It toStop is true, it terminates. OnStop just sets toStop and issues the pulse to gracefully terminate the worker thread. CleanupThread.csCleanupThread implements
Here is an example of cleanup.xml:
For each Repository, cleanup.xml contains
The CleanupThread restores cleanup.xml on an ArrayList of RepositoryEntry. At each loop, ThreadRun enumerates the ArrayList and calls for each Repository the Cleanup method of the Retry proxy. error writes an error entry on the Application Event log with a RepoCleanup source. log writes an information entry on the Application Event log with a RepoCleanup source if the logging mode, toLog is true. Retry.csRetry.cs is a SOAP proxy. It has been generated from the Retry Web service of the Repository using wsdl.exe. The constructor has been modified to set the Web service URL, which has to be the Repository URL. ProjectInstaller.csProjectInstaller.cs is a generated class responsible for the installation and de-installation of the Windows service. In .NET beta 2, we must set the service user and password. Even in Release version, because RepoCleanup can invoke Retry on other machines, we should use a network-enabled account with write access to the registry. To avoid hard coding the user and password, during installation and de-installation, ProjectInstaller prompts for the user name and password. TestRepoCleanupTestRepoCleanup was designed to test RepoCleanup functions. Therefore it includes the same classes as RepoCleanup:
You can use it to test your modifications. It is also user-friendlier than regedit and the Windows service startup parameters to set the registry entries. TestRepoCleanup uses a Windows form, TestCleanup. TestCleanup.csThe TestCleanup form contains two buttons, Start and Stop. The TestCleanup class contains three methods:
Contact:support@pagebox.net |
|